package com.scalar.chiptrack.operations.process.parser;

import java.util.LinkedList;
import java.util.Map;
import java.util.HashMap;

/**
 * User: Sujan
 * Date: Jul 14, 2008
 * Time: 3:31:38 PM
 */
public class BaseProduct
{
    private String baseProductName;
    private LinkedList activityList = new LinkedList();
    private LinkedList transitionList = new LinkedList();
    private int nextActivityId = 1;
    private int nextTransitionId = 1;
    private String prodGrp;
    private String packageId;
    private String packageSize;
    private String leadCount;
    private String testerFT;
    private String assy1; //assm location
    private String assy2;
    private String assy3;
    private String test1;
    private String test2;
    private String test3;
    private String fg1;
    private String fg2;  
    private int distance=160;
    private int verticalDistance = 50;
    private Map positionMap = new HashMap();
    
    public String getBaseProductName() {
        return baseProductName;
    }

    public void setBaseProductName(String baseProductName) {
        this.baseProductName = baseProductName;
    }

    public LinkedList getActivityList() {
        return activityList;
    }

    public void setActivityList(LinkedList activityList) {
        this.activityList = activityList;
    }

    public LinkedList getTransitionList() {
        return transitionList;
    }

    public void setTransitionList(LinkedList transitionList) {
        this.transitionList = transitionList;
    }
    public Activity getActivity ( String psType )
    {
        Activity activity = null;
        for ( int i=0; i < activityList.size(); i++ )
        {
            Activity tmp = (Activity)activityList.get(i);
            if ( psType.equalsIgnoreCase( tmp.getName() ) )
            {
                activity = tmp;
                break;
            }
        }
        return activity;
    }
    public Activity createActivity( String partNumber, String psType, String psTypeName )
    {
        Activity activity = new Activity();
        activity.setPartNumber( partNumber );
        activity.setType( psTypeName );
        activity.setName( psType );
        activity.setId( partNumber + "_Act_" + nextActivityId );
        nextActivityId++;
        activityList.add ( activity );
        return activity;
    }
    public Transition createTransition ( Activity from, Activity to )
    {
        Transition transition = new Transition();
        transition.setName( "" );
        transition.setId ( baseProductName + "_Tran_" + nextTransitionId );
        transition.setFrom( from.getId() );
        transition.setTo( to.getId() );
        nextTransitionId++;
        to.setX( from.getX()+distance );
        to.setY ( from.getY() );
        while ( positionMap.containsKey( "X"+to.getX()+"Y"+to.getY() ) )
        {
            to.setY( to.getY() + verticalDistance );
        }
        positionMap.put ( "X"+to.getX()+"Y"+to.getY(), "" );
        transitionList.add ( transition );
        return transition;
    }

    public String getProdGrp() {
        return prodGrp;
    }

    public void setProdGrp(String prodGrp) {
        this.prodGrp = prodGrp;
    }


    public String getPackageId() {
        return packageId;
    }

    public void setPackageId(String packageId) {
        this.packageId = packageId;
    }

    public String getPackageSize() {
        return packageSize;
    }

    public void setPackageSize(String packageSize) {
        this.packageSize = packageSize;
    }

    public String getLeadCount() {
        return leadCount;
    }

    public void setLeadCount(String leadCount) {
        this.leadCount = leadCount;
    }

    public String getTesterFT() {
        return testerFT;
    }

    public void setTesterFT(String testerFT) {
        this.testerFT = testerFT;
    }

    public String getAssy1() {
        return assy1;
    }

    public void setAssy1(String assy1) {
        this.assy1 = assy1;
    }

    public String getAssy2() {
        return assy2;
    }

    public void setAssy2(String assy2) {
        this.assy2 = assy2;
    }

    public String getAssy3() {
        return assy3;
    }

    public void setAssy3(String assy3) {
        this.assy3 = assy3;
    }

    public String getTest1() {
        return test1;
    }

    public void setTest1(String test1) {
        this.test1 = test1;
    }

    public String getTest2() {
        return test2;
    }

    public void setTest2(String test2) {
        this.test2 = test2;
    }

    public String getTest3() {
        return test3;
    }

    public void setTest3(String test3) {
        this.test3 = test3;
    }

    public String getFg1() {
        return fg1;
    }

    public void setFg1(String fg1) {
        this.fg1 = fg1;
    }

    public String getFg2() {
        return fg2;
    }

    public void setFg2(String fg2) {
        this.fg2 = fg2;
    }
}
